package com.org.shichui.controller;

import com.org.shichui.model.BaseResponse;
import com.org.shichui.pojo.RegForm;
import com.org.shichui.service.RegTelegramService;
import com.org.shichui.util.StringUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("regTele")
public class TelegramController {

    @Resource
    private RegTelegramService regTelegramService;
    /**
     * 注册电报
     * @return
     */
    @PostMapping("/toYmApi")
    public BaseResponse toYmApi(RegForm regForm){
        if(StringUtil.isBlank(regForm.getJiemaAccount())){
            return new BaseResponse(100,"接码平台账号不能为空",null);
        }
        if(StringUtil.isBlank(regForm.getJiemaAccount())){
            return new BaseResponse(100,"接码平台密码不能为空",null);
        }
        if(regForm.getRegCount()>50){
            return new BaseResponse(100,"一次最多不能超过50个",null);
        }
        if(StringUtil.isBlank(regForm.getId())){
            return new BaseResponse(100,"用户id不能为空",null);
        }
        return regTelegramService.toYmApi(regForm);
    }

}
